// 面包屑添加标签
layui.use(['layer','element',"form",'laypage','rate'], function(){
    var element = layui.element;
    var laypage = layui.laypage;


    laypage.render({
        elem: 'laypage-f' //注意，这里的 test1 是 ID，不用加 # 号
        ,count: 20 //数据总数，从服务端得到
        ,limit: 6
        ,groups:5
        ,theme: '#94A5FA'
        ,prev:'<'
        ,next:'>'
    });
    laypage.render({
        elem: 'laypage-s' //注意，这里的 test1 是 ID，不用加 # 号
        ,count: 20 //数据总数，从服务端得到
        ,limit: 6
        ,groups:5
        ,theme: '#94A5FA'
        ,prev:'<'
        ,next:'>'
    })

    var form = layui.form;

    //监听提交
    form.on('submit(formDemo)', function(data){
        layer.msg(JSON.stringify(data.field));
        return false;
    });


    // 星级评价
    var rate = layui.rate;
    rate.render({
        elem: '#com1'
        ,value: 5
        ,readonly: true
    });
    var rate = layui.rate;
    rate.render({
        elem: '#com2'
        ,value: 5
        ,readonly: true
    });
    var rate = layui.rate;
    rate.render({
        elem: '#com3'
        ,value: 5
        ,readonly: true
    });
    var rate = layui.rate;
    rate.render({
        elem: '#com4'
        ,value: 5
        ,readonly: true
    });
    var rate = layui.rate;
    rate.render({
        elem: '#com5'
        ,value: 5
        ,readonly: true
    });
});


// 评价选择
$('.com-level').on('click',function () {
    var index = $('.com-level').index(this);
    $('.com-level').removeClass('choose')
    $('.evaluate').removeClass('layui-icon-radio').addClass('layui-icon-circle');
    $(this).addClass('choose')
    $('.evaluate').eq(index).addClass('layui-icon-radio')
})

// 关闭遮罩层

$(".layui-icon-close").on("click",function () {
    $(".curse-fun").hide();
    $(this).parents().find('.hide-style').hide();
})

$(".sure-btn").on("click",function () {
    $(".curse-fun").hide();
    $(this).parents().find('.hide-style').hide();
    $('.ticket-get').text('10元课程优惠券  已领取')
})

// 领取优惠券

$(".ticket-get").on('click',function () {
    $(".curse-fun").show();
    $(".get-ticket").show()
})

function returnBuy() {
    $(".use-ticket").hide();
    $('.curse-buy').show()
}

$(".use-now").on('click',function () {
    returnBuy();
})
$(".layui-icon-left").on('click',function () {
    returnBuy();
})

$(".use-discounts").on('click',function () {
    $(".use-ticket").show();
    $('.curse-buy').hide()
})